
/*
===============================================================================
                    EntitySpaces Studio by EntitySpaces, LLC
             Persistence Layer and Business Objects for Microsoft .NET
             EntitySpaces(TM) is a legal trademark of EntitySpaces, LLC
                          http://www.entityspaces.net
===============================================================================
EntitySpaces Version : 2012.1.0930.0
EntitySpaces Driver  : SQL
Date Generated       : 2016/10/31 1:18:29
===============================================================================
*/

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using System.Data;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Runtime.Serialization;

using EntitySpaces.Core;
using EntitySpaces.Interfaces;
using EntitySpaces.DynamicQuery;



namespace yncTech.BusinessObjects
{
	/// <summary>
	/// Encapsulates the 'Fin_LendFlow' table
	/// </summary>

    [DebuggerDisplay("Data = {Debug}")]
	[Serializable]
	[DataContract]
	[KnownType(typeof(FinLendFlow))]	
	[XmlType("FinLendFlow")]
	public partial class FinLendFlow : esFinLendFlow
	{	
		[DebuggerBrowsable(DebuggerBrowsableState.RootHidden | DebuggerBrowsableState.Never)]
		protected override esEntityDebuggerView[] Debug
		{
			get { return base.Debug; }
		}

		override public esEntity CreateInstance()
		{
			return new FinLendFlow();
		}
		
		#region Static Quick Access Methods
		static public void Delete(System.Decimal folwId)
		{
			var obj = new FinLendFlow();
			obj.FolwId = folwId;
			obj.AcceptChanges();
			obj.MarkAsDeleted();
			obj.Save();
		}

	    static public void Delete(System.Decimal folwId, esSqlAccessType sqlAccessType)
		{
			var obj = new FinLendFlow();
			obj.FolwId = folwId;
			obj.AcceptChanges();
			obj.MarkAsDeleted();
			obj.Save(sqlAccessType);
		}
		#endregion

		
					
		
	
	}



    [DebuggerDisplay("Count = {Count}")]
	[Serializable]
	[CollectionDataContract]
	[XmlType("FinLendFlowCollection")]
	public partial class FinLendFlowCollection : esFinLendFlowCollection, IEnumerable<FinLendFlow>
	{
		public FinLendFlow FindByPrimaryKey(System.Decimal folwId)
		{
			return this.SingleOrDefault(e => e.FolwId == folwId);
		}

		
		
		#region WCF Service Class
		
		[DataContract]
		[KnownType(typeof(FinLendFlow))]
		public class FinLendFlowCollectionWCFPacket : esCollectionWCFPacket<FinLendFlowCollection>
		{
			public static implicit operator FinLendFlowCollection(FinLendFlowCollectionWCFPacket packet)
			{
				return packet.Collection;
			}

			public static implicit operator FinLendFlowCollectionWCFPacket(FinLendFlowCollection collection)
			{
				return new FinLendFlowCollectionWCFPacket() { Collection = collection };
			}
		}
		
		#endregion
		
				
	}



    [DebuggerDisplay("Query = {Parse()}")]
	[Serializable]	
	public partial class FinLendFlowQuery : esFinLendFlowQuery
	{
        public FinLendFlowQuery(): this("FinLendFlowQuery")
		{
		}
		public FinLendFlowQuery(string joinAlias)
		{
			this.es.JoinAlias = joinAlias;
		}	

		override protected string GetQueryName()
		{
			return "FinLendFlowQuery";
		}
		
					
	
		#region Explicit Casts
		
		public static explicit operator string(FinLendFlowQuery query)
		{
			return FinLendFlowQuery.SerializeHelper.ToXml(query);
		}

		public static explicit operator FinLendFlowQuery(string query)
		{
			return (FinLendFlowQuery)FinLendFlowQuery.SerializeHelper.FromXml(query, typeof(FinLendFlowQuery));
		}
		
		#endregion		
	}

	[DataContract]
	[Serializable]
	abstract public partial class esFinLendFlow : esEntity
	{
		public esFinLendFlow()
		{

		}
		
		#region LoadByPrimaryKey
		public virtual bool LoadByPrimaryKey(System.Decimal folwId)
		{
			if(this.es.Connection.SqlAccessType == esSqlAccessType.DynamicSQL)
				return LoadByPrimaryKeyDynamic(folwId);
			else
				return LoadByPrimaryKeyStoredProcedure(folwId);
		}

		public virtual bool LoadByPrimaryKey(esSqlAccessType sqlAccessType, System.Decimal folwId)
		{
			if (sqlAccessType == esSqlAccessType.DynamicSQL)
				return LoadByPrimaryKeyDynamic(folwId);
			else
				return LoadByPrimaryKeyStoredProcedure(folwId);
		}

		private bool LoadByPrimaryKeyDynamic(System.Decimal folwId)
		{
			FinLendFlowQuery query = new FinLendFlowQuery();
			query.Where(query.FolwId == folwId);
			return this.Load(query);
		}

		private bool LoadByPrimaryKeyStoredProcedure(System.Decimal folwId)
		{
			esParameters parms = new esParameters();
			parms.Add("FolwId", folwId);
			return this.Load(esQueryType.StoredProcedure, this.es.spLoadByPrimaryKey, parms);
		}
		#endregion
		
		#region Properties
		
		
		
		/// <summary>
		/// Maps to Fin_LendFlow.FolwId
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Decimal? FolwId
		{
			get
			{
				return base.GetSystemDecimal(FinLendFlowMetadata.ColumnNames.FolwId);
			}
			
			set
			{
				if(base.SetSystemDecimal(FinLendFlowMetadata.ColumnNames.FolwId, value))
				{
					OnPropertyChanged(FinLendFlowMetadata.PropertyNames.FolwId);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_LendFlow.LendId
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.Decimal? LendId
		{
			get
			{
				return base.GetSystemDecimal(FinLendFlowMetadata.ColumnNames.LendId);
			}
			
			set
			{
				if(base.SetSystemDecimal(FinLendFlowMetadata.ColumnNames.LendId, value))
				{
					OnPropertyChanged(FinLendFlowMetadata.PropertyNames.LendId);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_LendFlow.ActionTime
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? ActionTime
		{
			get
			{
				return base.GetSystemDateTime(FinLendFlowMetadata.ColumnNames.ActionTime);
			}
			
			set
			{
				if(base.SetSystemDateTime(FinLendFlowMetadata.ColumnNames.ActionTime, value))
				{
					OnPropertyChanged(FinLendFlowMetadata.PropertyNames.ActionTime);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_LendFlow.ActionTimeEnd
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.DateTime? ActionTimeEnd
		{
			get
			{
				return base.GetSystemDateTime(FinLendFlowMetadata.ColumnNames.ActionTimeEnd);
			}
			
			set
			{
				if(base.SetSystemDateTime(FinLendFlowMetadata.ColumnNames.ActionTimeEnd, value))
				{
					OnPropertyChanged(FinLendFlowMetadata.PropertyNames.ActionTimeEnd);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_LendFlow.ActionType
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String ActionType
		{
			get
			{
				return base.GetSystemString(FinLendFlowMetadata.ColumnNames.ActionType);
			}
			
			set
			{
				if(base.SetSystemString(FinLendFlowMetadata.ColumnNames.ActionType, value))
				{
					OnPropertyChanged(FinLendFlowMetadata.PropertyNames.ActionType);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_LendFlow.ActionMemo
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String ActionMemo
		{
			get
			{
				return base.GetSystemString(FinLendFlowMetadata.ColumnNames.ActionMemo);
			}
			
			set
			{
				if(base.SetSystemString(FinLendFlowMetadata.ColumnNames.ActionMemo, value))
				{
					OnPropertyChanged(FinLendFlowMetadata.PropertyNames.ActionMemo);
				}
			}
		}		
		
		/// <summary>
		/// Maps to Fin_LendFlow.CreateBy
		/// </summary>
		[DataMember(EmitDefaultValue=false)]
		virtual public System.String CreateBy
		{
			get
			{
				return base.GetSystemString(FinLendFlowMetadata.ColumnNames.CreateBy);
			}
			
			set
			{
				if(base.SetSystemString(FinLendFlowMetadata.ColumnNames.CreateBy, value))
				{
					OnPropertyChanged(FinLendFlowMetadata.PropertyNames.CreateBy);
				}
			}
		}		
		
		#endregion	

		#region .str() Properties
		
		public override void SetProperties(IDictionary values)
		{
			foreach (string propertyName in values.Keys)
			{
				this.SetProperty(propertyName, values[propertyName]);
			}
		}
		
		public override void SetProperty(string name, object value)
		{
			esColumnMetadata col = this.Meta.Columns.FindByPropertyName(name);
			if (col != null)
			{
				if(value == null || value is System.String)
				{				
					// Use the strongly typed property
					switch (name)
					{							
						case "FolwId": this.str().FolwId = (string)value; break;							
						case "LendId": this.str().LendId = (string)value; break;							
						case "ActionTime": this.str().ActionTime = (string)value; break;							
						case "ActionTimeEnd": this.str().ActionTimeEnd = (string)value; break;							
						case "ActionType": this.str().ActionType = (string)value; break;							
						case "ActionMemo": this.str().ActionMemo = (string)value; break;							
						case "CreateBy": this.str().CreateBy = (string)value; break;
					}
				}
				else
				{
					switch (name)
					{	
						case "FolwId":
						
							if (value == null || value is System.Decimal)
								this.FolwId = (System.Decimal?)value;
								OnPropertyChanged(FinLendFlowMetadata.PropertyNames.FolwId);
							break;
						
						case "LendId":
						
							if (value == null || value is System.Decimal)
								this.LendId = (System.Decimal?)value;
								OnPropertyChanged(FinLendFlowMetadata.PropertyNames.LendId);
							break;
						
						case "ActionTime":
						
							if (value == null || value is System.DateTime)
								this.ActionTime = (System.DateTime?)value;
								OnPropertyChanged(FinLendFlowMetadata.PropertyNames.ActionTime);
							break;
						
						case "ActionTimeEnd":
						
							if (value == null || value is System.DateTime)
								this.ActionTimeEnd = (System.DateTime?)value;
								OnPropertyChanged(FinLendFlowMetadata.PropertyNames.ActionTimeEnd);
							break;
					

						default:
							break;
					}
				}
			}
            else if (this.ContainsColumn(name))
            {
                this.SetColumn(name, value);
            }
			else
			{
				throw new Exception("SetProperty Error: '" + name + "' not found");
			}
		}		

		public esStrings str()
		{
			if (esstrings == null)
			{
				esstrings = new esStrings(this);
			}
			return esstrings;
		}

		sealed public class esStrings
		{
			public esStrings(esFinLendFlow entity)
			{
				this.entity = entity;
			}
			
	
			public System.String FolwId
			{
				get
				{
					System.Decimal? data = entity.FolwId;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.FolwId = null;
					else entity.FolwId = Convert.ToDecimal(value);
				}
			}
				
			public System.String LendId
			{
				get
				{
					System.Decimal? data = entity.LendId;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.LendId = null;
					else entity.LendId = Convert.ToDecimal(value);
				}
			}
				
			public System.String ActionTime
			{
				get
				{
					System.DateTime? data = entity.ActionTime;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.ActionTime = null;
					else entity.ActionTime = Convert.ToDateTime(value);
				}
			}
				
			public System.String ActionTimeEnd
			{
				get
				{
					System.DateTime? data = entity.ActionTimeEnd;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.ActionTimeEnd = null;
					else entity.ActionTimeEnd = Convert.ToDateTime(value);
				}
			}
				
			public System.String ActionType
			{
				get
				{
					System.String data = entity.ActionType;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.ActionType = null;
					else entity.ActionType = Convert.ToString(value);
				}
			}
				
			public System.String ActionMemo
			{
				get
				{
					System.String data = entity.ActionMemo;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.ActionMemo = null;
					else entity.ActionMemo = Convert.ToString(value);
				}
			}
				
			public System.String CreateBy
			{
				get
				{
					System.String data = entity.CreateBy;
					return (data == null) ? String.Empty : Convert.ToString(data);
				}

				set
				{
					if (value == null || value.Length == 0) entity.CreateBy = null;
					else entity.CreateBy = Convert.ToString(value);
				}
			}
			

			private esFinLendFlow entity;
		}
		
		[NonSerialized]
		private esStrings esstrings;		
		
		#endregion
		
		#region Housekeeping methods

		override protected IMetadata Meta
		{
			get
			{
				return FinLendFlowMetadata.Meta();
			}
		}

		#endregion		
		
		#region Query Logic

		public FinLendFlowQuery Query
		{
			get
			{
				if (this.query == null)
				{
					this.query = new FinLendFlowQuery();
					InitQuery(this.query);
				}

				return this.query;
			}
		}

		public bool Load(FinLendFlowQuery query)
		{
			this.query = query;
			InitQuery(this.query);
			return this.Query.Load();
		}
		
		protected void InitQuery(FinLendFlowQuery query)
		{
			query.OnLoadDelegate = this.OnQueryLoaded;
			
			if (!query.es2.HasConnection)
			{
				query.es2.Connection = ((IEntity)this).Connection;
			}			
		}

		#endregion
		
        [IgnoreDataMember]
		private FinLendFlowQuery query;		
	}



	[Serializable]
	abstract public partial class esFinLendFlowCollection : esEntityCollection<FinLendFlow>
	{
		#region Housekeeping methods
		override protected IMetadata Meta
		{
			get
			{
				return FinLendFlowMetadata.Meta();
			}
		}

		protected override string GetCollectionName()
		{
			return "FinLendFlowCollection";
		}

		#endregion		
		
		#region Query Logic

	#if (!WindowsCE)
		[BrowsableAttribute(false)]
	#endif
		public FinLendFlowQuery Query
		{
			get
			{
				if (this.query == null)
				{
					this.query = new FinLendFlowQuery();
					InitQuery(this.query);
				}

				return this.query;
			}
		}

		public bool Load(FinLendFlowQuery query)
		{
			this.query = query;
			InitQuery(this.query);
			return Query.Load();
		}

		override protected esDynamicQuery GetDynamicQuery()
		{
			if (this.query == null)
			{
				this.query = new FinLendFlowQuery();
				this.InitQuery(query);
			}
			return this.query;
		}

		protected void InitQuery(FinLendFlowQuery query)
		{
			query.OnLoadDelegate = this.OnQueryLoaded;
			
			if (!query.es2.HasConnection)
			{
				query.es2.Connection = ((IEntityCollection)this).Connection;
			}			
		}

		protected override void HookupQuery(esDynamicQuery query)
		{
			this.InitQuery((FinLendFlowQuery)query);
		}

		#endregion
		
		private FinLendFlowQuery query;
	}



	[Serializable]
	abstract public partial class esFinLendFlowQuery : esDynamicQuery
	{
		override protected IMetadata Meta
		{
			get
			{
				return FinLendFlowMetadata.Meta();
			}
		}	
		
		#region QueryItemFromName
		
        protected override esQueryItem QueryItemFromName(string name)
        {
            switch (name)
            {
				case "FolwId": return this.FolwId;
				case "LendId": return this.LendId;
				case "ActionTime": return this.ActionTime;
				case "ActionTimeEnd": return this.ActionTimeEnd;
				case "ActionType": return this.ActionType;
				case "ActionMemo": return this.ActionMemo;
				case "CreateBy": return this.CreateBy;

                default: return null;
            }
        }		
		
		#endregion
		
		#region esQueryItems

		public esQueryItem FolwId
		{
			get { return new esQueryItem(this, FinLendFlowMetadata.ColumnNames.FolwId, esSystemType.Decimal); }
		} 
		
		public esQueryItem LendId
		{
			get { return new esQueryItem(this, FinLendFlowMetadata.ColumnNames.LendId, esSystemType.Decimal); }
		} 
		
		public esQueryItem ActionTime
		{
			get { return new esQueryItem(this, FinLendFlowMetadata.ColumnNames.ActionTime, esSystemType.DateTime); }
		} 
		
		public esQueryItem ActionTimeEnd
		{
			get { return new esQueryItem(this, FinLendFlowMetadata.ColumnNames.ActionTimeEnd, esSystemType.DateTime); }
		} 
		
		public esQueryItem ActionType
		{
			get { return new esQueryItem(this, FinLendFlowMetadata.ColumnNames.ActionType, esSystemType.String); }
		} 
		
		public esQueryItem ActionMemo
		{
			get { return new esQueryItem(this, FinLendFlowMetadata.ColumnNames.ActionMemo, esSystemType.String); }
		} 
		
		public esQueryItem CreateBy
		{
			get { return new esQueryItem(this, FinLendFlowMetadata.ColumnNames.CreateBy, esSystemType.String); }
		} 
		
		#endregion
		
	}


	
	public partial class FinLendFlow : esFinLendFlow
	{

		
		
	}
	



	[Serializable]
	public partial class FinLendFlowMetadata : esMetadata, IMetadata
	{
		#region Protected Constructor
		protected FinLendFlowMetadata()
		{
			m_columns = new esColumnMetadataCollection();
			esColumnMetadata c;

			c = new esColumnMetadata(FinLendFlowMetadata.ColumnNames.FolwId, 0, typeof(System.Decimal), esSystemType.Decimal);
			c.PropertyName = FinLendFlowMetadata.PropertyNames.FolwId;
			c.IsInPrimaryKey = true;
			c.IsAutoIncrement = true;
			c.NumericPrecision = 18;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinLendFlowMetadata.ColumnNames.LendId, 1, typeof(System.Decimal), esSystemType.Decimal);
			c.PropertyName = FinLendFlowMetadata.PropertyNames.LendId;
			c.NumericPrecision = 18;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinLendFlowMetadata.ColumnNames.ActionTime, 2, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = FinLendFlowMetadata.PropertyNames.ActionTime;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinLendFlowMetadata.ColumnNames.ActionTimeEnd, 3, typeof(System.DateTime), esSystemType.DateTime);
			c.PropertyName = FinLendFlowMetadata.PropertyNames.ActionTimeEnd;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinLendFlowMetadata.ColumnNames.ActionType, 4, typeof(System.String), esSystemType.String);
			c.PropertyName = FinLendFlowMetadata.PropertyNames.ActionType;
			c.CharacterMaxLength = 50;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinLendFlowMetadata.ColumnNames.ActionMemo, 5, typeof(System.String), esSystemType.String);
			c.PropertyName = FinLendFlowMetadata.PropertyNames.ActionMemo;
			c.CharacterMaxLength = 1073741823;
			c.IsNullable = true;
			m_columns.Add(c);
				
			c = new esColumnMetadata(FinLendFlowMetadata.ColumnNames.CreateBy, 6, typeof(System.String), esSystemType.String);
			c.PropertyName = FinLendFlowMetadata.PropertyNames.CreateBy;
			c.CharacterMaxLength = 50;
			m_columns.Add(c);
				
		}
		#endregion	
	
		static public FinLendFlowMetadata Meta()
		{
			return meta;
		}	
		
		public Guid DataID
		{
			get { return base.m_dataID; }
		}	
		
		public bool MultiProviderMode
		{
			get { return false; }
		}		

		public esColumnMetadataCollection Columns
		{
			get	{ return base.m_columns; }
		}
		
		#region ColumnNames
		public class ColumnNames
		{ 
			 public const string FolwId = "FolwId";
			 public const string LendId = "LendId";
			 public const string ActionTime = "ActionTime";
			 public const string ActionTimeEnd = "ActionTimeEnd";
			 public const string ActionType = "ActionType";
			 public const string ActionMemo = "ActionMemo";
			 public const string CreateBy = "CreateBy";
		}
		#endregion	
		
		#region PropertyNames
		public class PropertyNames
		{ 
			 public const string FolwId = "FolwId";
			 public const string LendId = "LendId";
			 public const string ActionTime = "ActionTime";
			 public const string ActionTimeEnd = "ActionTimeEnd";
			 public const string ActionType = "ActionType";
			 public const string ActionMemo = "ActionMemo";
			 public const string CreateBy = "CreateBy";
		}
		#endregion	

		public esProviderSpecificMetadata GetProviderMetadata(string mapName)
		{
			MapToMeta mapMethod = mapDelegates[mapName];

			if (mapMethod != null)
				return mapMethod(mapName);
			else
				return null;
		}
		
		#region MAP esDefault
		
		static private int RegisterDelegateesDefault()
		{
			// This is only executed once per the life of the application
			lock (typeof(FinLendFlowMetadata))
			{
				if(FinLendFlowMetadata.mapDelegates == null)
				{
					FinLendFlowMetadata.mapDelegates = new Dictionary<string,MapToMeta>();
				}
				
				if (FinLendFlowMetadata.meta == null)
				{
					FinLendFlowMetadata.meta = new FinLendFlowMetadata();
				}
				
				MapToMeta mapMethod = new MapToMeta(meta.esDefault);
				mapDelegates.Add("esDefault", mapMethod);
				mapMethod("esDefault");
			}
			return 0;
		}			

		private esProviderSpecificMetadata esDefault(string mapName)
		{
			if(!m_providerMetadataMaps.ContainsKey(mapName))
			{
				esProviderSpecificMetadata meta = new esProviderSpecificMetadata();			


				meta.AddTypeMap("FolwId", new esTypeMap("numeric", "System.Decimal"));
				meta.AddTypeMap("LendId", new esTypeMap("numeric", "System.Decimal"));
				meta.AddTypeMap("ActionTime", new esTypeMap("datetime", "System.DateTime"));
				meta.AddTypeMap("ActionTimeEnd", new esTypeMap("datetime", "System.DateTime"));
				meta.AddTypeMap("ActionType", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("ActionMemo", new esTypeMap("nvarchar", "System.String"));
				meta.AddTypeMap("CreateBy", new esTypeMap("nvarchar", "System.String"));			
				
				
				
				meta.Source = "Fin_LendFlow";
				meta.Destination = "Fin_LendFlow";
				
				meta.spInsert = "proc_Fin_LendFlowInsert";				
				meta.spUpdate = "proc_Fin_LendFlowUpdate";		
				meta.spDelete = "proc_Fin_LendFlowDelete";
				meta.spLoadAll = "proc_Fin_LendFlowLoadAll";
				meta.spLoadByPrimaryKey = "proc_Fin_LendFlowLoadByPrimaryKey";
				
				this.m_providerMetadataMaps["esDefault"] = meta;
			}
			
			return this.m_providerMetadataMaps["esDefault"];
		}

		#endregion

		static private FinLendFlowMetadata meta;
		static protected Dictionary<string, MapToMeta> mapDelegates;
		static private int _esDefault = RegisterDelegateesDefault();
	}
}
